<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link rel="stylesheet" href="../../static/layui/css/layui.css">
    <link rel="stylesheet" href="../../static/css/main.css">
    <link rel="stylesheet" href="../../static/css/public.css">
    <script src="../../static/js/jquery-3.4.1.min.js"></script>
    <script src="../../static/layui/layui.js"></script>
    <style>
        .t{
            width: 100px
        }
    </style>
</head>
<body>
    <div class="er">
        <ul class="layui-nav layui-bg-cyan" id="top-nav">
            <li class="layui-nav-item">
                <a href="">首页</a>
            </li>
            <li class="layui-nav-item">
                <a href="">个人中心<span class="layui-badge-dot"></span></a>
            </li>
            <li class="layui-nav-item">
                <a href="#"><img src="../../static/images/2019-08-07/f8aa0870-e4ea-4170-9772-296204476267.jpg"
                                 class="layui-nav-img"
                                 text="'你好，'+${session.user.username}"></a>

            </li>
            <li class="layui-nav-item">
                <a href="">退出登录</a>

            </li>
        </ul>


    </div>
    <div class="left">
        <ul class="layui-nav layui-nav-tree  layui-nav-side" lay-filter="test" id="left">
            <li class="layui-nav-item" style="height: 60px"><a href="#" style="font-size:18px;font-family: 'Century Gothic';color: #bce8f1">suda物流系统</a></li>
            <li class="layui-nav-item layui-nav-itemed">
                <a href="javascript:;">物流信息</a>
                <dl class="layui-nav-child">
                    <dd><a href="../order/allorder.html" target="_top">订单列表</a></dd>
                    <dd><a href="../package/allpackage.html" target="_top">包裹信息</a></dd>
                    <dd><a href="../route/allroute.html" target="_top">运输信息</a></dd>
                    <dd><a href="../store/allstore.html" target="_top">存储信息</a></dd>
                    <dd><a href="../vehicle/allvehicle.html" target="_top">运输工具信息</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item layui-nav-itemed">
                <a href="javascript:;">物流管理</a>
                <dl class="layui-nav-child">
                    <dd><a href="../staff/allstaff.html" target="_top">员工列表</a></dd>

                    <dd><a href="../warehouse/allwarehouse.html" target="_top">仓库列表</a></dd>

                    <dd><a href="../customer/allcustomer.html" target="_top">顾客列表</a></dd>
                </dl>
            </li>
        </ul>

    </div>
    <div class="body">
        <h2 class="tablename">添加顾客</h2>
        <hr class="layui-bg-gray">
        <form class="layui-form">

            <div class="layui-form-item">
                <label class="layui-form-label t">顾客编号:</label>
                <div class="layui-input-inline">
                    <input type="text" id="customerId" value="" autocomplete="off" lay-verify="required"
                           class="layui-input" >
                </div>

                <label class="layui-form-label t">身份证号码:</label>
                <div class="layui-input-inline">
                    <input type="text" id="idNumber" value="" autocomplete="off" lay-verify="required"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label t">顾客名字:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="customerName" value="" lay-verify="required"
                               class="layui-input">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label t">常用地址:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="customerAddress" value="" lay-verify="required"
                               class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label t">联系电话:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="customerPhone" value="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label t">性别:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="gender" id="" value="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label t">顾客类型:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="customerType" value="" lay-verify="required"
                               class="layui-input">
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label t">欠费:</label>
                    <div class="layui-input-inline">
                        <input type="text" id="debt" value="" lay-verify="required"
                               class="layui-input">
                    </div>
                </div>
            </div>
            <br>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
                    <!--                    <input class="layui-btn layui-btn-radius layui-btn-normal" type="button" onclick="sub()" value="提交">-->
                    <button class="layui-btn layui-btn-radius layui-btn-normal" lay-submit lay-filter="*">添加</button>
                    &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
                    <button type="reset" class="layui-btn layui-btn-radius  layui-btn-danger">重置</button>
                </div>
            </div>
            <br>
        </form>

    </div>
    <div class="layui-footer" style="margin-top: 75px">
        <!-- 底部固定区域 -->
        <div class="bottom_left">
            <ul class="ul1">
                <li><a href="javascript:;">首页&nbsp;&nbsp;|&nbsp;</a></li>
                <li><a href="javascript:;">站点情况&nbsp;&nbsp;|&nbsp;</a></li>
                <li><a href="javascript:;">物流信息&nbsp;&nbsp;|&nbsp;</a></li>
                <li><a href="javascript:;">物流管理&nbsp;&nbsp;|&nbsp;</a></li>
                <li><a href="javascript:;">操作管理&nbsp;&nbsp;|&nbsp;</a></li>
                <li><a href="javascript:;">权限管理</a></li>

            </ul>
            <br> <br>
            <p>版权所有 Copyright &copy; 2021 皖ICP@Sun_Wangping</p>
            <p>技术支持： braisedPanda</p>
            <br>
        </div>

    </div>
<script>

    layui.use('element', function(){
        var element = layui.element;

        //…
    });

    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#receiveTime'
        });
        laydate.render({
            elem: '#actualDistriTime'
        });
        laydate.render({
            elem: '#estiDistriTime'
        });

        form.on('submit(*)', function(){
            var customersubmit = {
                "customerId" : document.getElementById('customerId').value,
                "idnumber" : document.getElementById('idNumber').value,
                "customerName" : document.getElementById('customerName').value,
                "customerAddress" : document.getElementById('customerAddress').value,
                "customerPhone" : document.getElementById('customerPhone').value,
                "gender" : document.getElementById('gender').value,
                "customerType" : document.getElementById('customerType').value,
                "debt" : document.getElementById('debt').value,
            }
            layer.confirm('确定添加吗？', {
                btn: ['是的','取消'] //按钮
            }, function(){
                $.ajax({
                    url: 'http://localhost:8080/customer',
                    type: 'POST',
                    contentType : 'application/json',
                    dataType: 'json',
                    data: JSON.stringify(customersubmit),
                    success(res){
                        var obj = JSON.stringify(res);

                        // alert(Object.keys(obj)[0]);
                        if(Object.keys(obj)[0] == 0)layer.msg("添加成功", {icon: '1', time: 2000});
                        else layer.msg("添加失败", {icon: '2', time: 2000});
                    },
                    error(){
                        layer.msg('500！', {
                            time: 1000, //不自动关闭
                            icon: 'layui-icon-ok',
                        });
                    }
                })
            }, function(){
                layer.msg('已取消', {
                    time: 2000
                });
            });
            return false;
        })


    });
</script>


</body>
</html>